# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=ngrep
pkgver=1.47
_pkgver="${pkgver/./_}"
pkgrel=3
pkgdesc="A grep-like utility that allows you to search for network packets on an interface"
url="https://ngrep.sourceforge.net/"
arch="all"
license="custom"
makedepends="autoconf automake libpcap-dev pcre-dev"
options="!check"
subpackages="$pkgname-dbg $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/jpr5/ngrep/archive/V$_pkgver.tar.gz"
builddir="$srcdir"/$pkgname-$_pkgver

prepare() {
	default_prepare
	update_config_sub
	autoreconf -vif
}

build() {
	export EXTRA_INCLUDES=$(pcre-config --cflags)
	export EXTRA_LIBS=$(pcre-config --libs)
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--enable-pcre \
		--enable-ipv6 \
		--with-pcap-includes=/usr/include/pcap \
		--disable-pcap-restart
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="47ba65878df6b555701c866721a8a935eabdcce636d398284cbfe5f63baf68c62d994a2f373ea4fc8f44fbed3eecee149f2ee48d39c71c04d34e5a088db8c657  ngrep-1.47.tar.gz"
